package be.ipl.pigolo.testUcc;

import static org.junit.Assert.assertEquals;

import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.Test;

import be.ipl.pigolo.domaine.Partie;
import be.ipl.pigolo.usecases.GestionPartie;

public class TestListerToutesLesParties {

	private static GestionPartie gp;
	private List<Partie> listePartieAvant;

	@Before
	public void setUp() throws Exception {
		try {
			Context jndi = new InitialContext();
			gp = (GestionPartie) jndi
					.lookup("ejb:PigoloEAR/PigoloEJB/GestionPartieImpl!be.ipl.pigolo.usecases.GestionPartie");
		} catch (NamingException e) {
			e.printStackTrace();
		}
		listePartieAvant = this.gp.listerToutesLesParties();
	}

	@Test
	public void testListerPartiesNull() {
		assertEquals(0, this.gp.listerToutesLesParties().size()-listePartieAvant.size());
	}

	@Test
	public void testListerPartiesValide() {
		this.gp.creerPartie("partie23",3);
		this.gp.creerPartie("partie24",3);
		this.gp.creerPartie("partie25",3);
		this.gp.creerPartie("partie26",3);
		assertEquals(4, this.gp.listerToutesLesParties().size()-listePartieAvant.size());
	}

}
